#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int minModifications(string s, string t)
{
	int m = s.length();
	int n = t.length();

	vector<vector<int>> dp(m + 1, vector<int>(n + 1, 0));

	for (int i = 1; i < m; i++)
	{
		for (int j = 1; j < n; j++)
		{
			if (s[i - 1] == t[j - 1])
			{
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else
			{
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}

	int lcslength = dp[m][n];

	return n - lcslength;
}

int main()
{
	string s, t;
	cin >> s >> t;

	int result = minModifications(s, t);
	cout << result << endl;

	return 0;
}